﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace A2Z.FrameWork
{
    public class StringRandom
    {
        static public string GenerateRandomIntCode(int length)
        {
            Random random = new Random();
            string s = string.Empty;
            for (int i = 0; i < length; i++)
                s = String.Concat(s, random.Next(10).ToString());
            return s;
        }
        static public string GenerateRandomStringCode(int length)
        {
           
            StringBuilder sb = new StringBuilder();
            char ch;
            Random rand = new Random();
            for (int i = 0; i < length; i++)
            {

                int choose = rand.Next(0, 9);

                if (choose < 5)

                    ch = Convert.ToChar(Convert.ToInt32(rand.Next(97, 122)));
                else if (4 < choose && choose < 8)
                    ch = Convert.ToChar(Convert.ToInt32(rand.Next(65, 90)));

                else
                    ch = Convert.ToChar(Convert.ToInt32(rand.Next(48, 57)));


                sb.Append(ch);
            }

            return sb.ToString();

           

        }
    }
}
